int i,j,k;
void setup()
{
    pinMode( 14, INPUT);
    pinMode( 18, INPUT);    
    pinMode( 5, OUTPUT);
    pinMode( 6, OUTPUT);
    pinMode( 9, OUTPUT);
    pinMode( 10, OUTPUT);
}

void loop()
{
      i=digitalRead(14);          //读取左侧黑标
      j=digitalRead(17);          //读取右侧黑标
      k=i&j;                      //读取两侧黑标
      

      if(i==0)                   
      {
            if(j==0)            //加速
            {               
                  analogWrite(5,225);
                  analogWrite(6,0);
                  analogWrite(9,195);
                  analogWrite(10,0); 
                  delay(300);
            }
        
            analogWrite(5,160);  //右转
            analogWrite(6,0);
            analogWrite(9,0);
            analogWrite(10,0); 
            delay(120);
          }
      
      if(j==0)  
      {
            if(i==0)
            {           
                  analogWrite(5,225);
                  analogWrite(6,0);
                  analogWrite(9,195);
                  analogWrite(10,0); 
                  delay(300);
             }
        
            analogWrite(5,0); //左转
            analogWrite(6,0);
            analogWrite(9,140);
            analogWrite(10,0); 
            delay(120);
      }

      if(k==1)               //无触发直行
      {
            analogWrite(5,135);
            analogWrite(6,0);
            analogWrite(9,100);
            analogWrite(10,0); 
      }
      
      else      
      {
            analogWrite(5,0);
            analogWrite(6,0);
            analogWrite(9,0);
            analogWrite(10,0);      
      }
}

